<template>
    <div class="box-wrap">
        <!-- <el-row :gutter="20">
            <el-col :span="4" v-for="(item,index) in dataList" :key="index">
                <div class="btn" :class="item.status | statusToColor" @click="goEnter()">{{ item.scodeName }}</div>
            </el-col>
        </el-row> -->
        <el-tree :data="dataList" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
        <el-dialog title="标题" :visible.sync="dialogVisible" :before-close="handleClose">
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="时间">
                    <el-date-picker v-model="dateRange" type="datetimerange" range-separator="至"
                        start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy:MM:dd HH:mm:ss">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="表名">
                    <el-select v-model="form.tableName"  placeholder="请选择">
                        <el-option v-for="item in options" :key="item.tableCode" :label="item.tableCodeName"
                            :value="item.tableCode">
                        </el-option>
                    </el-select>
                </el-form-item>
                <!-- <el-form-item label="操作">
                    <el-button size="small">按钮1</el-button>
                    <el-button size="small">按钮2</el-button>
                    <el-button size="small">按钮3</el-button>
                    <el-button size="small">按钮4</el-button>
                </el-form-item> -->
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="submitForm">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import Api from './api/api';
import EventUtils from "@/commons/events.js";

let parentInfo
export default {
    data() {
        return {
            dataList:[],
            defaultProps: {
                children: 'childList',
                label: 'scodeName'
            },
            dialogVisible:false,
            form: {
                startTime: '',
                endTime: '',
                sql:'',
                tableName:'',
                code:'',
                baqIp:'',
                sjzxIp:'',
            },
            options:[],
            dateRange:[],
            socket: new WebSocket("ws://127.0.0.1:10588")
        }
    },
    created(){
        this.getPtTree()

    
    },
    destroyed () {

    },
    methods: {
        //获取数据
        getPtTree(){
            let callBack = res => {
                this.dataList = res.data
            }
            Api.getPtTree({},callBack)
        },

        goEnter(){
            this.$router.push('/dataDetectionDetail')
        }
    },
    filters:{
        statusToColor(obj){
            let item={
                0:'red',
                1:'green'
            }
            return item[obj]
        }
    }
}
</script>
<style scoped>



.el-col{
    margin-bottom: 20px;
}

.box-wrap{
    width: 100%;
    height: calc(100% - 50px);
    padding: 30px;
    border: 1px solid #0b7b86;
        box-shadow: inset 0 0 12px 2px #0b7b86;
    box-sizing: border-box;
    min-width: 1300px;
}
.box-wrap .btn{
    width: 180px;
    height: 40px;
    text-align: center;
    line-height: 40px;
    border: 1px solid #0b7b86;
    border-radius: 20px;
    cursor: pointer;
}

.box-wrap .btn.green{
    background: #0b7b86;
}

.box-wrap .btn.red {
    background: #F56C6C;
    border-color: #F56C6C;
}

.tit{
    word-wrap: break-word;
}
</style>

